package com.leetcode.problems033;

/**
 * https://leetcode-cn.com/problems/substring-with-concatenation-of-all-words/
 * @Date 2021/11/20 14:34
 * @Author ghery
 * @Version V1.0
 */
public class Solution {


    public int search(int[] nums, int target) {
        return search(nums,0,nums.length - 1,target);
    }

    public int search(int[] nums,int l,int r, int target) {
        if(r < l){
            return -1;
        }
        int mid = (r - l) / 2 + l;
        if(nums[mid] == target){
            return mid;
        }

        int res = search(nums,l,mid - 1,target);
        if(res != -1){
            return res;
        }
        res = search(nums,mid + 1,r,target);
        return res;
    }

    public static void main(String[] args) {
        int[] words = {4,5,6,7,0,1,2};
        System.out.println(new Solution().search(words,8));
    }
}
